import pymysql
connect = pymysql.connect(
    host='127.0.0.1',
    db='study',
    user='root',
    password='mysql',
    port=3306,
    charset='utf8', )
# 创建游标
cur = connect.cursor()

# 1.创建表
sql = """
 create table Student(
    cno char(4)   primary key,
    name varchar(20) not null,
    age int not null,
    com  varchar(10) not null,
    salary float
 )
"""
cur.execute(sql)
print('创建成功!')


# 2.插入数据
sql = "insert into Student(cno, name, age, com, salary) values ('0001', '张三', 18, '副教授', 1888.0) ,('0002', '李四', 50, '教授', 7000.0),('0003', '王五', 70, '校长', 10000.2),('0004', '赵六', 19, '教师', 1010.5),('0005', '孙七', 35, '教师', 1500.3)"
cur.execute(sql)
connect.commit()
print('插入成功!')